package net.huashitong.ssydt.provider.sys.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.huashitong.ssydt.provider.sys.service.SysService;
import net.huashitong.ssydt.provider.web.model.Result;
import net.huashitong.ssydt.provider.web.utils.ResultUtils;
import net.huashitong.ssydt.sys.entity.SsSysBas;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.08.22
 */
@Api(value = "/api/sys/", tags = {"系统模块"})
@RestController
@RequestMapping("/api/sys")
public class ApiSysController {

    private SysService sysService;

    @Autowired
    public ApiSysController(SysService sysService) {
        this.sysService = sysService;
    }

    @ApiOperation(value = "获取参数列表", notes = "获取参数列表", produces = MediaType.APPLICATION_JSON_VALUE)
    @GetMapping("/bas/type/{basType}")
    public Result<ArrayList<SsSysBas>> basList(
            @ApiParam(value = "类型名称", required = true) @PathVariable("basType") String basType) {
        List<SsSysBas> list = sysService.basList(basType);
        return ResultUtils.getSuccessResultList(list);
    }


    @ApiOperation(value = "获取参数对象", notes = "获取参数对象", produces = MediaType.APPLICATION_JSON_VALUE)
    @GetMapping("/bas/type/{basType}/value/{dictValue}")
    public Result<SsSysBas> getBas(
            @ApiParam(value = "类型名称", required = true) @PathVariable("basType") String basType,
            @ApiParam(value = "字典值", required = true) @PathVariable("dictValue") String dictValue) {
        SsSysBas ssSysBas = sysService.getBas(basType, dictValue);
        return ResultUtils.getSuccessResults(ssSysBas);
    }


}
